package com.atguigu.mymvc.util;

import jakarta.servlet.ServletRequest;

import java.io.BufferedReader;
import java.io.IOException;

public class RequestUtil {
    public static Object readObject(ServletRequest request , Class clazz) throws IOException {
        BufferedReader br = request.getReader();
        StringBuilder stringBuilder = new StringBuilder();
        String str = null;
        while((str=br.readLine())!=null){
            stringBuilder.append(str);
        }
        str = stringBuilder.toString();
        return JsonUtil.fromJson(str,clazz);
    }
}
